I have to export a module to Word. There i have a template and i want to change the header text in this template.
What i wanted to do is looping through the Story Ranges until the Primary Header is found. Here is my script:
OleAutoObj objStoryRanges
oleGet(objDoc,"StoryRanges",objStoryRanges)
OleAutoObj objStoryRange
clear objArgBlock
put(objArgBlock, 1)
oleMethod(objStoryRanges, cMethodItem, objArgBlock, objStoryRange)
int temp = 0
oleGet(objStoryRange, "StoryType", temp)
while ((temp != wdPrimaryHeaderStory)){
OleAutoObj objStoryRangeNext
oleGet(objStoryRanges,"NextStoryRange",objStoryRangeNext)
objStoryRange = objStoryRangeNext
oleGet(objStoryRange, "StoryType", temp)
}
But i'm not able to step to the next story range with "NextStoryRange".
Any idea would be helpful as i am trying to do this for hours now.
SystemAdmin - Mon Feb 14 15:12:34 EST 2011 |
Re: Word OLE - Header editing Mathias Mamsch - Tue Feb 15 10:59:28 EST 2011
So header like footer, right? Not heading? Using google for "word vba change header" I find:
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = MyHeaderText
which does the trick for my word (translation to dxl as a practice for the reader) :-) Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|